﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Maps.MapControl.WPF;


namespace Shrestha.Data.EventModel
{
    public class TriEvent: IEvent
    {
        public const string DateFormatter = "yyyy-MM-dd";

        public DateTime EventDate { get; set; }

        public String EventCharacter { get; set; }
        public String EventDescription { get; set; }

        public double EventLatitude { get; set; }
        public double EventLongitude { get; set; }

        public Location EventLocation { get { return new Location(EventLatitude, EventLongitude); } }

        public String EventDbDate { get { return EventDate.ToString(DateFormatter); } }

        public TriEvent(double Latitude, double Longitude, DateTime dt, String Character, String Description)
        {
            EventLatitude = Latitude;
            EventLongitude = Longitude;
            EventDate = dt;
            EventCharacter = Character;
            EventDescription = Description;
        }

        public TriEvent(double Latitude, double Longitude, DateTime dt)
        {
            EventLatitude = Latitude;
            EventLongitude = Longitude;
            EventDate = dt;
        }

        public TriEvent(double Latitude, double Longitude, String datetime)
        {
            EventLatitude = Latitude;
            EventLongitude = Longitude;
            EventDate = DateTime.Parse(datetime);
        }

        public TriEvent(Location loc, String datetime)
        {
            EventLatitude = loc.Latitude;
            EventLongitude = loc.Longitude;
            EventDate = DateTime.Parse(datetime);
        }
        
        public TriEvent() { }

        public bool HasCharacter { get { return (EventCharacter == null) ? false : true; } }
        public bool HasDescription { get { return (EventDescription == null) ? false : true; } }

        public int CompareTo(object obj)
        {
            TriEvent tx = obj as TriEvent;
            return (this.EventDate.Equals(tx.EventDate) && this.EventLocation.Equals(tx.EventLocation)) ? 1 : 0;
        }
    }
}
